package com.xyht.sca_s.student_manage_system.modules.rxRegistration.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.annotation.RequestPass;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.rxRegistration.entity.req.RxRegistrationPlanDetailSettingReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistration.entity.req.RxRegistrationPlanSettingReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistration.service.RxRegistrationPlanSettingService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 招生计划设置 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-05-07
 */
@RestController
@RequestMapping("/rxRegistrationPlan/setting")
@SecretBody
public class RxRegistrationPlanSettingController {
    @Resource
    private RxRegistrationPlanSettingService rxRegistrationPlanSettingService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;

    @PostMapping("/add")
    @ApiModelProperty("添加招生计划")
    public ResponseResult addRxRegistrationChargeCategory(@RequestBody RxRegistrationPlanSettingReq planSettingReq, HttpServletRequest request){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return rxRegistrationPlanSettingService.addRxRegistrationPlanSetting(planSettingReq,userId);
    }
    @PostMapping("/update")
    @ApiModelProperty("修改招生计划")
    public ResponseResult updateRxRegistrationPlanSetting(@RequestBody RxRegistrationPlanSettingReq planSettingReq){
        return rxRegistrationPlanSettingService.updateRxRegistrationPlanSetting(planSettingReq);
    }
    @PostMapping("/delete")
    @ApiModelProperty("删除招生计划")
    public ResponseResult deleteRxRegistrationPlanSetting(@RequestBody RxRegistrationPlanSettingReq planSettingReq){
        return rxRegistrationPlanSettingService.deleteRxRegistrationPlanSetting(planSettingReq);
    }
    @GetMapping("/list")
    @ApiModelProperty("获取招生计划列表")
    public ResponseResult getRxRegistrationPlanSettingList(@RequestParam(value = "searchStr", required = false) String searchStr,
                                                           @RequestParam(value = "status", required = false) Integer status,
                                                           @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
        return rxRegistrationPlanSettingService.getRxRegistrationPlanSettingList(searchStr, status, pageNum, pageSize);
    }

    @PostMapping("/detail/addAndUpdate")
    @ApiModelProperty("添加或修改招生计划详情")
    public ResponseResult addAndUpdateRxRegistrationPlanDetailSetting(@RequestBody RxRegistrationPlanDetailSettingReq planDetailSettingReq){
        return rxRegistrationPlanSettingService.addAndUpdateRxRegistrationPlanDetailSetting(planDetailSettingReq);
    }

    @GetMapping("/detail/get")
    @ApiModelProperty("获取招生计划详情")
    public ResponseResult getRxRegistrationPlanDetailSetting(@RequestParam(value = "appType") Integer appType,
                                                             @RequestParam(value = "planId") String planId){
        return rxRegistrationPlanSettingService.getRxRegistrationPlanDetailSetting(appType,planId);
    }


    @GetMapping("/getSuccessStatement")
    @ApiOperation("获取各阶段成功提示语句")
    @RequestPass
    public ResponseResult getSuccessStatement(@RequestParam(value = "idCard") String idCard,
                                              @RequestParam(value = "appType") Integer appType){
        return rxRegistrationPlanSettingService.getSuccessStatement(idCard,appType);
    }
    @GetMapping("/checkChargeCategory")
    @ApiOperation("校验收费项主项是否存在其他阶段中")
    @RequestPass
    public ResponseResult checkRxRegistrationChargeCategory(@RequestParam("chargeCategoryId") String chargeCategoryId,
                                                            @RequestParam("planId")  String planId){
        return rxRegistrationPlanSettingService.checkRxRegistrationChargeCategory(chargeCategoryId, planId);
    }








}

